/**
 * Demonstrates a range of Button options the framework offers out of the box
 */
Ext.define('cloud.view.homepic.HomePic', {
    extend: 'Ext.navigation.View',
    xtype: 'homePic',
    requires: ['Ext.List', 'Ext.TitleBar', 'Ext.field.Select', 'Ext.field.Search'],
    config: {
        defaultBackButtonText:'返回',
        items:
        {
            xtype: 'container',
            layout: 'card',
            title: '首页滚动广告',
            items: [
                {
                    xtype: 'toolbar',
                    docked: 'bottom',
                    layout: {
                        type: 'hbox',
                        pack: 'center'
                    },
                    items: [
                        {
                            xtype: 'button',
                            id: 'adpic_add',
                            cls:'x-button2',
                            iconMask: true,
                            text:'添加'
                        }
                    ]
                },
                {
                    xtype: 'toolbar',
                    ui: 'dark',
                    docked: 'top',
                    items: [
                        {
                            xtype: 'textfield',
                            id: 'adpic_search',
                            name: 'adpic_search',
                            placeHolder: '请输入广告名'
                        },
                        {xtype: 'spacer'},
                        {
                            xtype: 'selectfield',
                            id: 'adpic_sort',
                            name: 'adpic_sort',
                            width: 130,
                            options: [
                                {
                                    text: '选择排序方式',
                                    value: ''
                                },
                                {
                                    text: '按应广告名升序排列',
                                    value: 'adpicName_asc'
                                },
                                {
                                    text: '按广告名降序排列',
                                    value: 'adpicName_desc'
                                }
                            ]
                        }
                    ]
                },
                {
                    xtype: 'list',
                    title: '首页广告列表',
                    store: 'AdpicDistrictFindStore',
                    pressedCls:false,
                    selectedCls:false,
                    cls:'x-list2',
                    onItemDisclosure: true,
                    emptyText: '暂无广告',
                    itemTpl:
                        '<div class="listIcon"><img src="{picUrl}" /></div>'+
                        '<div class="listName">{name}  </div>'+
                            '<div class="listConten">' +
//                            '<span>ID: {cdaid}</span>' +
                            '<span>排序: {display}</span>' +
                            '</div>',
                    listeners:{
                        initialize:function(){

                            var adpic= Ext.getStore('AdpicDistrictFindStore');
                            adpic.load({params:{cadid:localStorage.getItem('cadid')}})
                            adpic.getProxy().setExtraParam('cadid',localStorage.getItem('cadid'))
                        }
                    } ,
                    plugins: [
                        {
                            xclass: 'Ext.plugin.PullRefresh',
                            pullRefreshText: '下拉可以更新',
                            releaseRefreshText: '松开开始更新',
                            style:'top:12px',
                            loadingText: '正在刷新……',
                            refreshFn: function (loaded, arguments) {
                                //loaded.getList().getStore().getProxy().setExtraParam('cadid',localStorage.getItem('cadid')); //设置proxy参数
                                loaded.getList().getStore().loadPage(1, {
                                    callback: function (record, operation, success) {
                                        Ext.Viewport.unmask();
                                    }, scope: this });
                            }
                        },
                        {
                            xclass: 'Ext.plugin.ListPaging',
                            loadMoreText: '<h2 style="text-align: center; padding-top: 20px; padding-bottom: 20px;">点击加载更多。。。。</h2>',
                            noMoreRecordsText: '<h2 style="text-align: center; padding-top: 20px; padding-bottom: 20px;">没有更多条记录了</h2>',
                            autoPaging: false //设置为TRUE将自动触发
                        }
                    ]
                }
            ]
        }
    }
});